<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<style>
		.boxLeft {
			display:inline-block;
			width:50% ;
			position:absolute;
			top:100px;
			bottom:15px;
			left:0px
		}
		.boxRight {
			display:inline-block;
			width:50% ;
			position:absolute;
			top:100px;
			bottom:15px;
			right:0px
		}
		.pageStyles {
			font-family: Arial,sans-serif;
			color: #333;
			background: #f5f5f5;
			font-size: 14px;
			line-height: 1.5;
		}
		h1 {
			font-size: 28px;
			line-height: 1.25;
			font-weight: normal;
		}
		em {
		  font-weight: bold;
		}
		.logo {
			margin-right: 10px;
			float: left;
			width: 48px;
			height: 48px;
			border-radius: 50%;
			border: 0;
			margin: 0;
			padding: 0;
			border-radius:0;
		}
		.titleContent {
			white-space:nowrap;
		}
	</style>
	<script type="text/javascript">

	console.API;

	if (typeof console._commandLineAPI !== 'undefined') {
		console.API = console._commandLineAPI; //chrome
	} else if (typeof console._inspectorCommandLineAPI !== 'undefined') {
		console.API = console._inspectorCommandLineAPI; //Safari
	} else if (typeof console.clear !== 'undefined') {
		console.API = console;
	}

	function swapJSBuild() {
		var button = document.getElementById("swapJsButton");
		var JS_RELEASE = "JS-Release";
		var JS_DEBUG = "JS-Debug";
		var SWAP_TO_RELEASE = "Swap To "+JS_RELEASE;
		var SWAP_TO_DEBUG = "Swap To "+JS_DEBUG;
		var base = "../target/javascript/bin";
		var debug = base + "/js-debug/index.html";
		var release = base + "/js-release/index.html";
		var jsIframe = document.getElementById("jsIframe");
		var status = document.getElementById("jsStatus");
		if (button && jsIframe) {
			var current = button.innerHTML;
			switch (current) {
				case SWAP_TO_RELEASE:
					console.API.clear();
					button.innerHTML = SWAP_TO_DEBUG;
					jsIframe.src = release;
					status.innerHTML = "Currently showing <em>"+JS_RELEASE+"</em>";;
				break;
				case SWAP_TO_DEBUG:
					console.API.clear();
					button.innerHTML = SWAP_TO_RELEASE;
					jsIframe.src = debug;
					status.innerHTML = "Currently showing <em>"+JS_DEBUG+"</em>";
				break;
			}
		}
	}


	function onSwfFrameReady(){
        //this supports intellij's 'launch in browser'
        var swfFrameSource = "/target/swf/UnitTests.html";
        if (window.location.search) {
           var append = window.location.search;
           if (append) swfFrameSource += append;
           console.log('appending url params:',swfFrameSource)
		}
        if ( document.getElementById('swfIframe').src.indexOf(swfFrameSource) == -1) {
            console.log(document.getElementById('swfIframe').src)
            document.getElementById('swfIframe').src =".."+swfFrameSource;
        }
	}
	</script>
</head>
<body class="pageStyles">
	<div>
		<div >
			<img class="logo" src="image/apache-royale-main-logo.png" alt="Apache Royale logo">
			<div class="titleContent">
				<h1>Royale Framework Development Unit Tests</h1>
			</div>
		<div id="jsStatus" style="position: relative; display: inline-block;">Currently showing <em>JS-Debug</em></div>
			<button id="swapJsButton" onclick="swapJSBuild()" type="button" class="quoteButton TextButton" style="position: relative; display: inline-block;">Swap To JS-Release</button>
		</div>
		<div class="boxLeft">
			<iframe id="jsIframe" src="../target/javascript/bin/js-debug/index.html" frameborder="1" scrolling="no" height="100%" width="100%" align="left" ></iframe>
		</div>
		<div class="boxRight">
			<iframe id="swfIframe" onload="onSwfFrameReady()"  frameborder="1" scrolling="no" height="100%" width="100%" align="left" ></iframe>
		</div>
	</div>
</body>
</html>
